package com.zhim.controller.demo;

import org.slf4j.bridge.SLF4JBridgeHandler;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Zyang on 2018/2/26.
 */
@Controller
@RequestMapping("/demo/LogTest")
public class LogTestController {

    private static final java.util.logging.Logger jucLogger = java.util.logging.Logger.getLogger(LogTestController.class.getName());
    private static final org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(LogTestController.class);
    private static final org.apache.commons.logging.Log commonLogger = org.apache.commons.logging.LogFactory.getLog(LogTestController.class);
    private static final org.slf4j.Logger slf4jLogger = org.slf4j.LoggerFactory.getLogger(LogTestController.class);

    private void logWithJuc() {
        jucLogger.info("java util logging...");
    }

    private void logWithLog4j() {
        log4jLogger.info("log4j...");
    }

    private void logWithCommonLogging() {
        commonLogger.info("common logging...");
    }

    private void logWithSlf4j() {
        slf4jLogger.info("slf4j...");
    }


    @ResponseBody
    @RequestMapping("/log")
    public String log(Model model) {
        logWithJuc();
        logWithLog4j();
        logWithCommonLogging();
        logWithSlf4j();
        return "success";
    }
}
